package com.nameless.controller.api;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.nameless.dao.OrderDao;
import com.nameless.entity.Order;
import com.nameless.vo.Result;
import org.aspectj.weaver.ast.Or;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author keluoyisi
 * @program: car-parent
 * @description: 订单接口
 * @date 2023-03-10 14:47:09
 */
@SuppressWarnings("all")
@RestController
@RequestMapping("/car/api/order")
public class OrderControllerApi {
    @Autowired
    private OrderDao orderDao;
    @PostMapping("/updateOrder/{orderNo}/{totalPrice}")
    public Result updateOrder(@PathVariable String orderNo,@PathVariable double totalPrice){
        QueryWrapper<Order> wrapper = new QueryWrapper<>();
        wrapper.eq("orderNo",orderNo);
        Order order = orderDao.selectOne(wrapper);
        order.setState(4);
        order.setTotalPrice(totalPrice);
        orderDao.updateById(order);
        return new Result(200,"支付成功");
    }

    @PostMapping("/updateOrders")
    public Result updateOrders(@RequestBody Order order1){
        QueryWrapper<Order> wrapper = new QueryWrapper<>();
        wrapper.eq("orderNo",order1.getOrderNo());
        Order order = orderDao.selectOne(wrapper);
        order.setState(4);
        order.setTotalPrice(order1.getTotalPrice());
        orderDao.updateById(order);
        return new Result(200,"支付成功");
    }
}
